package com.kikyou.service.impl;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kikyou.mapper.PositionLevelMapper;
import com.kikyou.pojo.Position;
import com.kikyou.pojo.PositionLevel;
import com.kikyou.pojo.RespBean;
import com.kikyou.service.IOplogService;
import com.kikyou.service.IPositionLevelService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @program: kikyouback
 * @author: 李玉龙
 * @create: 2022-03-07 19:25
 **/
@Service
public class PositionLevelServiceImpl extends ServiceImpl<PositionLevelMapper, PositionLevel> implements IPositionLevelService {
    @Autowired(required = false)
    PositionLevelMapper positionLevelMapper;
    @Autowired(required = false)
    IOplogService iOplogService;
    /**
    * @Description: 分页查询
    * @Param: * @param null
    * @return:  RespBean
    * @Author: 李玉龙
    * @Date: 11:40 2022/3/9
    */
    @Override
    public RespBean getAllOrgaLevels( int currentPage,  int pageSize){
        Page<PositionLevel> page= new Page(currentPage,pageSize);
        positionLevelMapper.selectPage(page,null);
        if (page != null) {
            return RespBean.success("职位级别查询成功",page);
        }
        return RespBean.error("职位级别查询失败");
    }
    /**
    * @Description: 创建
    * @Param: * @param null
    * @return:  RespBean
    * @Author: 李玉龙
    * @Date: 11:40 2022/3/9
    */
    @Override
    public RespBean PostOrgaLevels(PositionLevel positionLevel){
        int cont = positionLevelMapper.insert(positionLevel);
        if (cont!=0) {
            iOplogService.insertMessage("创建职位级别成功");
            return RespBean.success("创建职位级别成功");
        }
        return RespBean.error("创建职位级别失败");
    }
    /**
    * @Description: 编辑
    * @Param: * @param null
    * @return:  RespBean
    * @Author: 李玉龙
    * @Date: 11:40 2022/3/9
    */
    @Override
    public RespBean PutOrgaLevels(PositionLevel positionLevel){
        int b = positionLevelMapper.updateById(positionLevel);
        if (b!=0) {
            iOplogService.insertMessage("编辑职位级别成功");
            return RespBean.success("编辑职位级别成功");
        }
        return RespBean.error("编辑职位级别失败");
    }
}
